<template>
  <el-main>
    <el-table :height="tableHeight" :data="tableList" border stripe>
      <el-table-column prop="payParkMonth" label="所属月份" />
      <el-table-column prop="payParkMoney" label="缴费金额" />
      <el-table-column label="缴费状态" prop="payParkStatus">
        <template slot-scope="scope">
          <el-tag
            v-if="scope.row.payParkStatus == '0'"
            type="danger"
            size="small"
          >未缴费</el-tag>
          <el-tag
            v-if="scope.row.payParkStatus == '1'"
            type="success"
            size="small"
          >已缴费</el-tag>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      :current-page.sync="parms.currentPage"
      :page-sizes="[10,20, 40, 80, 100]"
      :page-size="parms.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="parms.total"
      background
      @size-change="sizeChange"
      @current-change="currentChange"
    />
  </el-main>
</template>

<script>
import { getMyParkFeeApi } from '@/api/myFee'
import { getUserId } from '@/utils/auth'
export default {
  data() {
    return {
      // 表格高度
      tableHeight: 0,
      // 表格数据
      tableList: [],
      parms: {
        pageSize: 10,
        currentPage: 1,
        userId: getUserId(),
        total: 0
      }
    }
  },
  created() {
    this.getList()
  },
  mounted() {
    this.$nextTick(() => {
      this.tableHeight = window.innerHeight - 200
    })
  },
  methods: {
    // 页数改变时触发
    currentChange(val) {
      this.parms.currentPage = val
      this.getList()
    },
    // 页容量变化时触发
    sizeChange(val) {
      this.parms.pageSize = val
      this.getList()
    },
    // 获取列表
    async getList() {
      const res = await getMyParkFeeApi(this.parms)
      if (res && res.code === 200) {
        console.log(res)
        this.tableList = res.extend.list.records
        this.parms.total = res.extend.list.total
      }
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
